package com.hs.jhzd.utils;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
@Component
public class ToolUtils {

	private static String jsbh;

	public static String getJsbh() {
		return jsbh;
	}
	@Value("${jsbh}")
	public  void setJsbh(String jsbh) {
		ToolUtils.jsbh = jsbh;
	}

	public  static String  CreatePrimaryKey(String oldId){
		if (oldId == null || oldId.length()<4) {
			SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
			return jsbh+format.format(new Date())+"0001";
		} else {
			String newId= oldId.substring(0,oldId.length() - 4)+String.format("%04d",Integer.parseInt(oldId.substring(oldId.length() - 4))+1);
			return  newId;
		}
	}
}
